package com.toman.ui.work.device;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;

import com.toman.Adpter.MyExpandableListPreviewHotAdapter;
import com.toman.Enum.BaseEnum;
import com.toman.Enum.PermEnum;
import com.toman.JavaBean.BeltlineInspectEntity;
import com.toman.JavaBean.TerminalWarmUpDto;
import com.toman.R;
import com.toman.Util.PermissonUtils;
import com.toman.Util.SPUtils;
import com.toman.Util.ToastUtil;
import com.toman.Util.ViewUtil;
import com.toman.toolbar.ToolBarActivity;
import com.toman.widget.CustomerExpandableListView;

import java.util.ArrayList;

import butterknife.BindView;
import cn.bingoogolapple.refreshlayout.BGARefreshLayout;

public class PreHot2Activity extends ToolBarActivity {
    @BindView(R.id.lv)
    CustomerExpandableListView mStateExpandable;

    private ArrayList<ArrayList<TerminalWarmUpDto>> array = new ArrayList<ArrayList<TerminalWarmUpDto>>();
    private ArrayList<String> arrayList = new ArrayList<String>();
    MyExpandableListPreviewHotAdapter adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_pre_hot2);
        initToolBar("远程预热");
        initList();
        initView();
    }

    private void initList() {
        ;
        arrayList = new ArrayList<String>() {{
            add("报警");
            add("待检查");
            add("油泵启动");
            add("正常预热");

        }};


        array = new ArrayList<>();
        for (int i = 0; i < arrayList.size(); i++) {
            ArrayList<TerminalWarmUpDto> list = new ArrayList<>(5);
            list.add(new TerminalWarmUpDto(i+"",i+"","产线"+i,"设备"+i,i*100L,i+""));
            list.add(new TerminalWarmUpDto(i+"",i+"","产线"+i,"设备"+i,i*100L,i+""));
            list.add(new TerminalWarmUpDto(i+"",i+"","产线"+i,"设备"+i,i*100L,i+""));
            list.add(new TerminalWarmUpDto(i+"",i+"","产线"+i,"设备"+i,i*100L,i+""));



            array.add(list);
        }
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.toolbar_add, menu);
        MenuItem menuItem = menu.findItem(R.id.menu_add);
        if (!PermissonUtils.contains(this, BaseEnum.SHIFT.has(PermEnum.ADD))) {
            menuItem.setVisible(false);
        }
        toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                switch (item.getItemId()) {
                    case R.id.menu_add:
                        ToastUtil.print("select："+ViewUtil.getPreviewHot(adapter.getSelectedList()));
                        adapter.selectContrary();
                        ToastUtil.print("selected："+ViewUtil.getPreviewHot(adapter.getSelectedList()));

                        break;
                }
                return false;
            }
        });
        return true;
    }
    private void initView() {
        adapter = new MyExpandableListPreviewHotAdapter(this, arrayList, array);
        mStateExpandable.setAdapter(adapter);
        for (int i=0; i<arrayList.size(); i++)
        {
            mStateExpandable.expandGroup(i);
        };

    }
}
